Highlighting Errors

The resulting output from a compile command can produce many hundreds of lines, even when successful.  Examining every line of output for warnings or errors is not only time consuming, but missing a vital error can lead to many lost hours of precious development time.

The solution to this problem is to allow Programmer Studio to only identify possible warnings and errors in the compiler output, highlighting each offending line for closer examination.  As Programmer Studio provides no specific compiler support, this detection of errors is achieved using regular expressions.

Regular Expressions

Regular expressions are ideal for identifying errors and warnings appearing in compiler output as they can be used to describe the general format of an error without being too specific.

Unlike finding text, the regular expressions used for error highlighting must also include special identifiers that indicate the position of file names and line numbers within the expression itself. In addition to the standard regular expression format characters, Programmer Studio uses the following variables to identify key elements in the compiler output.

To match

Use

The line index on which the error was detected.

<l>

The name of the file containing the error

<p> / <f>

The line number appearing on the line on which the error was detected. This is intended for COBOL compilers, etc.

<ln>

The name of the file containing the error in MPE format

<mp>

The line number on which the error was detected in MPE format

<mln>

The file name detected using the <p> variable is evaluated using the location at which the compile command was executed. This allows partial file names to be fully qualified.

The following examples illustrate how to create a regular expression to detect possible errors within the sample compiler output.  To help in identification, the special expression variables appear in bold.

Output:

cc: "hello.c", line 3: error 1507: Function...

Expression:

^cc: <f>, line <l>: error

 

Output:

/usr/examples/hello.c(3) : error...

Expression:

^<f>\(<l>\) : error

 

Output:

File: /usr/examples/hello.c

Line 3

Expression:

^File: <f>

^Line <l>

Although the regular expressions are explained in great detail in Using Regular Expressions, there are some initial points of interest when discussing the examples above.